//
//  YCHomeButton.m
//  lianganyuchu
//
//  Created by iMac on 17/2/22.
//  Copyright © 2017年 杭州桑缇电子商务有限公司. All rights reserved.
//

#import "YCHomeButton.h"

@interface YCHomeButton()
{
    UILabel *m_labTitle;
    UIImageView *m_imageView;
    
    UIView *m_pointView;
}
@end
@implementation YCHomeButton

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self addSubviewsWith:frame];
    }
    return self;
}
-(void)addSubviewsWith:(CGRect)frame
{
    CGSize sizeBtn=frame.size;
    
    CGFloat X=(sizeBtn.width-S(35))/2;
    m_imageView=[[UIImageView alloc]initWithFrame:CGRectMake(X, 20, S(35), S(35))];
    [self addSubview:m_imageView];
    
    m_pointView=[[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(m_imageView.frame), CGRectGetMinY(m_imageView.frame), 8, 8)];
    [m_pointView setBackgroundColor:MAIN_COLOR];
    m_pointView.layer.cornerRadius=4.0f;
    m_pointView.layer.masksToBounds=YES;
    [self addSubview:m_pointView];
    [m_pointView setHidden:YES];
    
    m_labTitle=[[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(m_imageView.frame)+kDistance, sizeBtn.width, 20)];
    [m_labTitle setTextColor:TEXT_LIGHT];
    [m_labTitle setFont:[UIFont LightFontOfSize:15]];
    [m_labTitle setTextAlignment:NSTextAlignmentCenter];
    [self addSubview:m_labTitle];
}
-(void)setButtonWith:(NSString *)title Image:(NSString *)image
{
    [m_labTitle setText:title];
    [m_imageView setImage:[UIImage imageNamed:image]];
}
-(void)showNewComment:(BOOL)hasData
{
    [m_pointView setHidden:!hasData];
}
@end
